<%@ page language="java" contentType="text/html; charset=UTF-8"
         pageEncoding="UTF-8" %>
<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <title>注册页面</title>
    <style>
        body {
            display: flex;
            justify-content: center;
            align-items: center;
            height: 100vh;
        }

        .container {
            width: 400px;
            text-align: center;
            background-color: #f0f0f0;
            padding: 40px;
            border-radius: 10px;
            box-shadow: 0px 0px 10px #aaa;
        }

        input[type="text"],
        input[type="password"] {
            display: block;
            margin: 20px auto;
            padding: 10px;
            width: 100%;
            border-radius: 5px;
            border: none;
            box-shadow: 0px 0px 5px #aaa inset;
            font-size: 16px;
        }

        button[type="submit"] {
            display: block;
            margin: 20px auto 0;
            padding: 10px 20px;
            background-color: #007bff;
            color: #fff;
            border-radius: 5px;
            border: none;
            font-size: 16px;
            cursor: pointer;
            transition: background-color 0.3s ease;
        }

        button[type="submit"]:hover {
            background-color: #0056b3;
        }

        .register-link {
            display: block;
            margin-top: 20px;
            font-size: 14px;
            text-align: center;
        }

        .register-link a {
            color: #007bff;
            text-decoration: none;
        }

        .register-link a:hover {
            text-decoration: underline;
        }
    </style>
</head>
<body>
<div class="container">
    <h1>注册页面</h1>
    <form action="/register" method="post">
        <label for="username">账户名:</label>
        <input type="text" id="username" name="username">

        <label for="password">密码:</label>
        <input type="password" id="password" name="password">

        <label for="confirm_password">确认密码:</label>
        <input type="password" id="confirm_password" name="confirm_password">

        <button type="submit" value="注册" onclick="validateForm()">登录</button>
    </form>
    <div class="register-link">
        已有账号？<a href="login.jsp">点击登录</a>
    </div>
</div>

<script>
    function validateForm() {
        var username = document.forms[0]["username"].value;
        var password = document.forms[0]["password"].value;
        var confirm_password = document.forms[0]["confirm_password"].value;

        if (username == "" || password == "" || confirm_password == "") {
            alert("请填写所有字段");
            return false;
        }

        if (password != confirm_password) {
            alert("两次密码不一致");
            return false;
        }


        // alert("注册成功");
        return true;
    }
</script>
</body>
</html>
